﻿using AutoMapper;
using NP.BPMReportPlatform.BaseData.Dto;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.Entities.BPM_Platform;
using NP.BPMReportPlatform.RecurringJobs.Dto;
using NP.BPMReportPlatform.StandardApprovalFlow.Dto;
using System;
using NP.BPMReportPlatform.FrameOrder.Dto;
using NP.BPMReportPlatform.SystemSettings.Dto;
using NP.BPMReportPlatform.RecurringJobs.Dto.FlowManager;
using NP.BPMReportPlatform.AuthorizationProcessesManager.Dtos;
using NP.BPMReportPlatform.Entities.BPM_Process;
using NP.BPMReportPlatform.HR.Dto;
using NP.BPMReportPlatform.EmpCertification.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dtos;
using NP.BPMReportPlatform.TaxManage.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using NP.BPMReportPlatform.Holiday.Dto;
using NP.BPMReportPlatform.Reports.OrderMaterialDetail.Dtos;
using NP.BPMReportPlatform.Entities.BPM_Business.Reports;
using Volo.Abp.AutoMapper;
using NP.BPMReportPlatform.Entities.BPM_Engine;
using System.Collections.Generic;
using Volo.Abp.ObjectMapping;
using NP.BPMReportPlatform.Entities.BPM_Business.PKPT;

namespace NP.BPMReportPlatform
{
    public class BPMReportPlatformApplicationAutoMapperProfile : Profile
    {
        public BPMReportPlatformApplicationAutoMapperProfile()
        {
            /* You can configure your AutoMapper mapping configuration here.
             * Alternatively, you can split your mapping configurations
             * into multiple profile classes for a better organization. */

            CreateMap<StandardApproval, GetStandardApprovalOutput>().ReverseMap();

            CreateMap<KeyValues, GetKeyValuesOutput>().ReverseMap();

            CreateMap<ExportStandardApprovalOutput, GetStandardApprovalOutput>().ReverseMap();
            CreateMap<GetStandardApprovalOutput, ExportStandardApproval90Output>().ReverseMap();
            CreateMap<GetStandardApprovalOutput, ExportStandardApprovalBZDWOutput>().ReverseMap();
            CreateMap<GetStandardApprovalOutput, ExportStandardApprovalJJBCOutput>().ReverseMap();

            CreateMap<OrgDto, Organizations>().ReverseMap();
            CreateMap<Organizations, OrgDto>().ReverseMap();

            //用户扩展属性模型映射
            CreateMap<UserExtensionDto, UserExtension>().ReverseMap();
            CreateMap<SyncUserDto, UserExtension>().ReverseMap();

            CreateMap<UserPositionRelations, UserPositionRelationsDto>().ReverseMap();
            CreateMap<Positions, PositionsDto>().ReverseMap();

            CreateMap<Positions, UserOrganizationPostionDto>()
                .ForMember(a => a.PositionId, b => b.MapFrom(c => c.PositionId))
                .ForMember(a => a.OrganizationId, b => b.MapFrom(c => c.OrganizationId))
                .ForMember(a => a.PositionCode, b => b.MapFrom(c => c.PositionCode));

            CreateMap<UserPositionRelations, UserOrganizationPostionDto>()
                .ForMember(a => a.PositionId, b => b.MapFrom(c => c.PositionId))
                .ForMember(a => a.UserId, b => b.MapFrom(c => c.UserId))
                .ForMember(a => a.UserPositionRelationId, b => b.MapFrom(c => c.UserPositionRelationId));

            CreateMap<SyncOrgDto, Organizations>()
                .ForMember(a => a.Name, b => b.MapFrom(c => c.SText))
                .ForMember(a => a.Name2, b => b.MapFrom(c => c.Short))
                .ForMember(a => a.DeptCode, b => b.MapFrom(c => c.ObjId))
                .ForMember(a => a.ParentDeptCode, b => b.MapFrom(c => c.SObId))
                .ForMember(a => a.Status, b => b.MapFrom(c => 1));
            CreateMap<SyncUserDto, Users>()
                .ForMember(a => a.UserId, b => b.MapFrom(c => Guid.NewGuid()))
                .ForMember(a => a.UserName, b => b.MapFrom(c => c.Name))
                .ForMember(a => a.Password, b => b.MapFrom(c => "fCIvspJ9goryL1khNOiTJIBjfA0="))
                .ForMember(a => a.UserType, b => b.MapFrom(c => "E"))
                .ForMember(a => a.UserLoginId, b => b.MapFrom(c => c.LoginName))
                .ForMember(a => a.WorkNumber, b => b.MapFrom(c => c.SAPEmployeeId))
                .ForMember(a => a.Source, b => b.MapFrom(c => c.Id))
                .ForMember(a => a.Gender, b => b.MapFrom(c => c.Sex == 1 ? "M" : "F"))
                .ForMember(a => a.Email, b => b.MapFrom(c => c.Email))
                .ForMember(a => a.Status, b => b.MapFrom(c => (c.Status == 3 && c.IsDelete == false) ? 1 : 0))
                .ForMember(a => a.ResignationDate, b => b.MapFrom(c => c.Leavedate))
                .ForMember(a => a.DeptCode, b => b.MapFrom(c => c.Org))
                .ForMember(a => a.ModifyDate, b => b.MapFrom(c => DateTime.Now));

            // 车辆购置补贴模型映射
            CreateMap<GetFrameOrderOutput, GetCLFrameOrderOutput>().ReverseMap();
            // 交通费用报销模型映射
            CreateMap<GetFrameOrderOutput, GetJTFrameOrderOutput>().ReverseMap();

            // 人事驻外补贴模型映射
            CreateMap<GetFrameOrderOutput, GetRSZWBTFrameOrderOutput>().ReverseMap();

            // 特殊配置实体映射
            CreateMap<LeaveSpecialApproverEntity, Leave.Dto.SpecialApproverDto.ExportOutput>().ReverseMap();

            // 人事驻外补贴导出实体映射
            CreateMap<FrameOrderChildrszwbt, FrameOrderChildrszwbtOutput>().ReverseMap();


            //审批配置模型映射
            CreateMap<ApproverConfiguration, GetApproveConfigurationOutput>().ReverseMap();
            CreateMap<ApproverConfiguration, SaveApproveConfigurationInput>().ReverseMap();

            CreateMap<HRProcessApprovalConfiguration, SaveApproveConfigInput>().ReverseMap();
            CreateMap<HRProcessApprovalConfiguration, GetApproveConfigOutput>().ReverseMap();
            CreateMap<PhoneFeeLimitConfig, GetPhoneFeeLimitConfigOutput>().ReverseMap();
            CreateMap<SavePhoneFeeLimitConfigInput,PhoneFeeLimitConfig>().ReverseMap();

            CreateMap<StandardApproval, FlowInstanceDto>().ReverseMap();
            CreateMap<AuthorizationProcessesSettings, GetUserAuthorizationProcessesOutput>().ReverseMap();

            CreateMap<WeChatUserDto, WeChatUser>()
                .ForMember(a => a.UserName, b => b.MapFrom(c => c.Name))
                .ForMember(a => a.UserLoginId, b => b.MapFrom(c => c.UserId))
                .ForMember(a => a.EmployeeCode, b => b.MapFrom(c => c.UserId))
                .ForMember(a => a.Phone, b => b.MapFrom(c => c.Mobile));

            CreateMap<WeChatUser, GetWechatUserOutput>().ReverseMap();
            CreateMap<OrgLeader, GetOrgLeaderDto>().ReverseMap();

            // 特殊配置实体映射
            CreateMap<LeaveSpecialApproverEntity, Leave.Dto.SpecialApproverDto.ExportOutput>().ReverseMap();

            // 员工证明映射模型
            CreateMap<GetEmpCertResultOutput, EmpCertExportDto>().ReverseMap();
            CreateMap<TaxApplyContent, TaxApplyContentDto>().ReverseMap();

            CreateMap<LCZXRZXQGLConfig, LCZXRZXQGLConfigInputDto>().ReverseMap();

            CreateMap<PKBudgetData, GetPKBudgetDataOutput>().ReverseMap();
            CreateMap<PKBudgetData, PKBudgetDataOutput>().ReverseMap();
            CreateMap<PKSubmittedByPrincipalDetail, GetPKSubmittedByPrincipalDetailOutput>();
            CreateMap<PKHolidays, HolidayResultDto>();
            CreateMap<HolidayInput, PKHolidays>();
            CreateMap<PKHolidays, ExportHoliday>();
            CreateMap<ExportHoliday, PKHolidays>();

            CreateMap<OrderMaterialDetailDto, OrderMaterialDetailEntity>()
                .ForMember(a => a.AddTime, b => b.MapFrom(c => DateTime.Now))
                .ForMember(a => a.Id, b => b.MapFrom(c => Guid.NewGuid()));
            CreateMap<EndProductPlanDto, OrderMaterialEndProductPlan>().ReverseMap();
            CreateMap<OrderMaterialConfigDto, OrderMaterialConfigEntity>()
                .ForMember(a => a.Id, b => b.MapFrom(c => Guid.NewGuid()));
            CreateMap<AvailableInventoryDto, OrderMaterialAvailableInventory>().ReverseMap();

            CreateMap<RecordsHistory, Records>().ReverseMap();

            CreateMap<PKSubmittedByPrincipal, PKSubmittedByPrincipal_DeleteRecord>().ReverseMap();
            CreateMap<PKSubmittedByPrincipalDetail, PKSubmittedByPrincipalDetail_DeleteRecord>().ReverseMap();
            CreateMap<PKSubmittedByPrincipalHistory, PKSubmittedByPrincipalHistory_DeleteRecord>().ReverseMap();
        }
    }
}